function url(s) {
  return `${window.RPConfig.mgt}/resource/${s}`;
}

// resouce list
//export const queryResouceList = param => $http.post(url("list/page"), param);

export function queryResouceList(param) {
  return $http.post(url("list/page"), param).then(res => res.data);
}

export const queryResouceListForCode = param =>
  $http.get(
    url(
      `listByCondition?applicationId=${param.applicationId}&type=${param.resourceType}&code=${param.resourceCode}&limit=${param.size}`
    )
  );

// resouce tree
export const queryResouceTree = param => $http.post(url("sub/list"), param);

// Add Resource
export const addResource = param => $http.post(url("add"), param);

// update by id
export const updateResource = param => $http.post(url("updateById"), param);

// delete
export const deleteResource = param => $http.post(url("delete"), param);
// 删除资源关系
export const deleteByIdAndParentId = param => $http.post(url("deleteByIdAndParentId"), param);

// mount 挂载资源
export const mountResource = param => $http.post(url("mount"), param);

// 获取未分配的api资源
export const pageResUnallocated = param => $http.post(url("list/pageResUnallocated"), param);

// 获取已分配的api资源
export const pageMount = param => $http.post(url("list/pageMount"), param);

// 分配资源
export const batchMount = param => $http.post(url("batchMount"), param);

// 删除已分配的资源
export const deleteResUnallocated = param => $http.post(url("unload"), param);

// 获取当前功能下的父UI资源
export const getParentUi = param => $http.post(url("list/resource"), param);
